from src.formats.ReadZipFiles import ReadZipFile
import os


def getSrcPath():
    return os.path.dirname(os.path.dirname(os.path.realpath(__file__)))


class C3DTilesManager:
    def __init__(self, filePath):
        self.srcPath = getSrcPath()
        # 打包文件路径
        self.filePath = filePath
        # 打包文件zipFile对象,提供读取打包文件内文件的方法
        self.tilesFile = ReadZipFile(filePath)
        self.tilePath = 'Data/'

    def getJson(self, filename):
        json = self.tilesFile.readSubFile(filename + '.json')
        return json

    # 获取瓦片目录下的文件
    def getTileFile(self, tilename, filename):
        file = self.tilesFile.readSubFile(self.tilePath + tilename + '/' + filename)
        return file

    # 获取根目录下的文件
    def getFile_fromRoot(self, tilename, filename):
        file = self.tilesFile.readSubFile(tilename + '/' + filename)
        return file
